package com.tear.language.node;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 *  节点工厂
 */
public class NodeFactory {
	
	private static Map<String,BaseNode> nodeMap = new ConcurrentHashMap<String,BaseNode>();
	
	static {
		nodeMap.put("in", new InNode());
		nodeMap.put("def", new DefNode());
		nodeMap.put("set", new SetNode());
		nodeMap.put("add", new SetNode());
		nodeMap.put("if", new IfNode());
		nodeMap.put("else", new ElseNode());
		nodeMap.put("choose", new ChooseNode());
		nodeMap.put("when", new WhenNode());
		nodeMap.put("other", new OtherNode());
		nodeMap.put("service", new ServiceNode());
		nodeMap.put("while", new WhileNode());
		nodeMap.put("result", new ResultNode());
		nodeMap.put("print", new PrintNode());
		nodeMap.put("test", new TestNode());
		nodeMap.put("return", new ReturnNode());
		nodeMap.put("transactional", new TransactionNode());
	}
	
	public static void addNode(String nodeName,BaseNode node) {
		
		nodeMap.put(nodeName, node);
		
	}
	
	public static BaseNode create(String nodeName) {
		
		
		return nodeMap.get(nodeName);
		
	}
	
	public static BaseNode create(String nodeName,String code) {
		
		return nodeMap.get(nodeName);
		
	}
}
